package org.clearjerk.model;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class XMLReader {
	
	private HashMap<String, String> results;
	
	public XMLReader(String fname) throws IOException {
		File loadfile = new File(fname);
		System.out.println(loadfile.getAbsolutePath());
		BufferedReader br;
		results = new HashMap<String,String>();
		br = new BufferedReader(new InputStreamReader(new DataInputStream(new FileInputStream(loadfile))));
		String line;
		while ((line = br.readLine()) != null)   {
			if(line.contains("<"))
				results.put(line.substring(line.indexOf("<")+1, line.indexOf(">")), line.substring(line.indexOf(">")+1,line.lastIndexOf("<")));
		}
	}
	
	public HashMap<String,String> getInfo() {
		return results;
	}
}
